package com.atguigu.classroom.vod.controller;


import com.atguigu.classroom.model.vod.Subject;
import com.atguigu.classroom.result.Result;
import com.atguigu.classroom.vod.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2022-07-08
 */
@Api(tags = "课程分类接口")
@RestController
@RequestMapping("/admin/vod/subject/")
public class SubjectController {
    @Autowired
    private SubjectService subjectService;
    @ApiOperation("树状课程分类查询")
    @GetMapping("getChildSubject/{id}")
    public Result getChildSubject(@PathVariable Long id){
        List<Subject> subjectList=subjectService.getSubjects(id);
        return Result.ok(subjectList);
    }
    @ApiOperation("课程分类到出excel表格")
    @GetMapping("exportData")
    public void exportData(HttpServletResponse response){
        subjectService.exportData(response);
    }
    @ApiOperation("excel课程分类表格数据导入")
    @PostMapping("importData")
    public Result importData(MultipartFile file){
        subjectService.importData(file);
        return Result.ok("导入成功");
    }
}

